﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace DimensionAddIn.Windows
{
    public partial class BusyIndicatorForm : Form
    {
        private Action _proAction;

        public BusyIndicatorForm()
        {
            InitializeComponent();
        }

        public void InvokeClose()
        {
            this.Invoke(new EventHandler(OnInvokeClose));
        }

        private void OnInvokeClose(object sender, EventArgs e)
        {
            this.Close();
        }

        public void ShowMask(Action proAction)
        {
            _proAction = proAction;
            Thread thread = new Thread(Run);
            thread.Start();
            this.ShowDialog();
        }

        private void Run()
        {
            _proAction();
            this.InvokeClose();
        }
    }
}
